package com.ruoyi.web.controller.food;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.entity.Result;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GrainWarehouse;
import com.ruoyi.system.service.IGrainWarehouseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2025-04-02
 */
@RestController
@RequestMapping("/warehouse")
@Api(tags = "【请填写功能名称】")
public class GrainWarehouseController extends BaseController<GrainWarehouse>
{
    @Autowired
    private IGrainWarehouseService grainWarehouseService;

    /**
     * 查询【请填写功能名称】列表-分页
     */
    @ApiOperation(value = "查询【请填写功能名称】列表-分页")
    @PreAuthorize("@ss.hasPermi('web:warehouse:page')")
    @GetMapping("/page")
    public Result<List<GrainWarehouse>> page(GrainWarehouse grainWarehouse)
    {
        startPage();
        List<GrainWarehouse> list = grainWarehouseService.selectGrainWarehouseList(grainWarehouse);
        return getPageTable(list);
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @ApiOperation(value = "查询【请填写功能名称】列表")
    @PreAuthorize("@ss.hasPermi('web:warehouse:list')")
    @GetMapping("/list")
    public Result<List<GrainWarehouse>> list(GrainWarehouse grainWarehouse)
    {
        List<GrainWarehouse> list = grainWarehouseService.selectGrainWarehouseList(grainWarehouse);
        return Result.ok(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @ApiOperation(value = "导出【请填写功能名称】列表")
    @PreAuthorize("@ss.hasPermi('web:warehouse:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GrainWarehouse grainWarehouse)
    {
        List<GrainWarehouse> list = grainWarehouseService.selectGrainWarehouseList(grainWarehouse);
        ExcelUtil<GrainWarehouse> util = new ExcelUtil<GrainWarehouse>(GrainWarehouse.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @ApiOperation(value = "获取【请填写功能名称】详细信息")
    @PreAuthorize("@ss.hasPermi('web:warehouse:query')")
    @GetMapping(value = "/{warehouseId}")
    public Result<GrainWarehouse> getInfo(@PathVariable("warehouseId") Long warehouseId)
    {
        return Result.ok(grainWarehouseService.selectGrainWarehouseByWarehouseId(warehouseId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @ApiOperation(value = "新增【请填写功能名称】")
    @PreAuthorize("@ss.hasPermi('web:warehouse:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody GrainWarehouse grainWarehouse)
    {
        return Result.ok(grainWarehouseService.insertGrainWarehouse(grainWarehouse));
    }

    /**
     * 修改【请填写功能名称】
     */
    @ApiOperation(value = "修改【请填写功能名称】")
    @PreAuthorize("@ss.hasPermi('web:warehouse:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody GrainWarehouse grainWarehouse)
    {
        return Result.ok(grainWarehouseService.updateGrainWarehouse(grainWarehouse));
    }

    /**
     * 删除【请填写功能名称】
     */
    @ApiOperation(value = "删除【请填写功能名称】")
    @PreAuthorize("@ss.hasPermi('web:warehouse:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warehouseIds}")
    public Result remove(@PathVariable Long[] warehouseIds)
    {
        return Result.ok(grainWarehouseService.deleteGrainWarehouseByWarehouseIds(warehouseIds));
    }

    @ApiOperation(value = "获取仓房列表")
    @GetMapping("/getList")
    public Result<List<GrainWarehouse>> getWarehouseList(){
        List<GrainWarehouse> result = grainWarehouseService.getWarehouseList();
        return Result.ok(result);
    }
}
